<!DOCTYPE HTML>
<html>
<head>
<title>店铺管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>

<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />

<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />

<!-- font-awesome icons CSS -->
<link href="css/font-awesome.css" rel="stylesheet"> 
<!-- //font-awesome icons CSS -->

 <!-- side nav css file -->
 <link href='css/SidebarNav.min.css' media='all' rel='stylesheet' type='text/css'/>
 <!-- side nav css file -->
<link href='css/commodity.css' media='all' rel='stylesheet' type='text/css'/>

 <!-- js-->
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/modernizr.custom.js"></script>

<!--webfonts-->
<link href="http://fonts.googleapis.com/css?family=PT+Sans:400,400i,700,700i&amp;subset=cyrillic,cyrillic-ext,latin-ext" rel="stylesheet">
<!--//webfonts--> 

<!-- Metis Menu -->
<script src="js/metisMenu.min.js"></script>
<script src="js/custom.js"></script>
<link href="css/custom.css" rel="stylesheet">
<!--//Metis Menu -->

<!-- calendar -->
<link rel="stylesheet" href="css/monthly.css">
<!-- //calendar -->

</head> 
<body class="cbp-spmenu-push">
	<div class="main-content">
	<div class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
		<!--left-fixed -navigation-->
		<aside class="sidebar-left">
      <nav class="navbar navbar-inverse">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".collapse" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </button>
            <h1><a class="navbar-brand" href="index.html"><span class="fa fa-pie-chart"></span>智能工程管理平台</a></h1>
          </div>
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="sidebar-menu">
              <li class="header">MAIN NAVIGATION</li>
              <li class="treeview">
                <a href="index.html">
                <i class="fa fa-dashboard"></i> <span>首 页</span>
                </a>
              </li>
			  <li class="treeview">
                <a href="#">
                <i class="fa fa-th"></i>
                <span>分类管理</span>
                <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                  <li><a href="classify.html"><i class="fa fa-angle-right"></i>材料分类</a></li>
                </ul>
              </li>
              <li class="treeview">
                <a href="#">
               <i class="fa fa-laptop"></i>
                <span>材料管理</span>
                <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                  <li><a href="commodity.html"><i class="fa fa-angle-right"></i>材料列表</a></li>
                  <li><a href="new-goods.html"><i class="fa fa-angle-right"></i>添加材料</a></li>
                </ul>
              </li>
               <li class="treeview">
                <a href="#">
                <i class="fa fa-edit"></i>
                <span>项目管理</span>
                <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                    <li><a href="Message.html"><i class="fa fa-angle-right"></i>进度报告</a></li>
                    <li><a href="Base.html"><i class="fa fa-angle-right"></i>检测报告</a></li>
                    <li><a href="Mountain.html"><i class="fa fa-angle-right"></i>员工考核</a></li>
                    <li><a href="media.html"><i class="fa fa-angle-right"></i>新增项目</a></li>
                </ul>
              </li>
              <li class="treeview">
                <a href="charts.html">
                <i class="fa fa-pie-chart"></i>
                <span>公告管理</span>

                </a>
              </li>
              <li class="treeview">
              <li class="treeview">
                <a href="#">
                <i class="fa fa-laptop"></i>
                <span>用户管理</span>
                <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                  <li><a href="user.html"><i class="fa fa-angle-right"></i>用户列表</a></li>
                  <li><a href="new-user.html"><i class="fa fa-angle-right"></i>新增用户</a></li>
                </ul>
              </li>
			  <li>
                <a href="literature.html">
                <i class="fa fa-th"></i> <span>施工规范</span>

                </a>
              </li>
               <li class="treeview">
                <a href="#">
                <i class="fa fa-folder"></i> <span>仓库管理</span>
                <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
					<li><a href="tool.html"><i class="fa fa-angle-right"></i>工具管理</a></li>
					<li><a href="vacation.html"><i class="fa fa-angle-right"></i>仓库统计</a></li>
                </ul>
              </li>
                <li class="treeview"> <a href="userStatistics.html"> <i class="fa fa-pie-chart"></i> <span>合格率统计</span> </a> </li>
            </ul>
          </div>
          <!-- /.navbar-collapse -->
      </nav>
    </aside>
	</div>
		<!--left-fixed -navigation-->
		
		<!-- header-starts -->
		<div class="sticky-header header-section ">
			<div class="header-left">
				
				<!--toggle button start-->
				<button id="showLeftPush"><i class="fa fa-bars"></i></button>
				<!--toggle button end-->
				<!--notification menu end -->
				<div class="clearfix"> </div>
			</div>

			<div class="clearfix"> </div>	
		</div>
		<!-- //header-ends -->
		<!-- main content start-->
		<div id="page-wrapper">
			<div class="main-page">
				
				<div class="elements">
                	<div class="col-sm-12 w3-agileits-crd widgettable">
                            <div class="card">
                                <div class="card-body">
							<div class="agileinfo-cdr">
                               <ul id="myTabs" class="nav nav-tabs" role="tablist"> 
                                    <li role="presentation" class=""><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">门店列表</a></li>
                                    <li role="presentation" class="active"><a href="#profile" role="tab" id="profile-tab" data-toggle="tab" aria-controls="profile" aria-expanded="false">添加门店</a></li>
                               </ul> 
                               <div id="myTabContent" class="tab-content scrollbar1">
								   <div role="tabpanel" class="tab-pane fade" id="home" aria-labelledby="home-tab">

								   </div>
								   <div id="updateShop" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
									   <div class="modal-dialog" role="document">
										   <div class="modal-content">
											   <div class="modal-header">
												   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
												   <h4 class="modal-title">修改店铺信息</h4>
											   </div>
											   <div class="modal-body">
												   <form>
													   <div class="form-group">
														   <label class="control-label">店铺名称</label>
														   <input id="updateShopName" type="text" class="form-control">
													   </div>
													   <div class="form-group">
														   <label class="control-label">店铺标题</label>
														   <textarea id="updateShopBanner" class="form-control" ></textarea>
													   </div>
													   <div class="form-group">
														   <label class="control-label">店铺简介</label>
														   <textarea id="updateShopBriefIntroduction" class="form-control" ></textarea>
													   </div>
													   <div class="form-group">
														   <label class="control-label">店铺介绍</label>
														   <textarea id="updateShopIntroduce" class="form-control" ></textarea>
													   </div>
												   </form>
											   </div>
											   <div class="modal-footer">
												   <button type="button" class="btn btn-default" onclick="updateShop()" data-dismiss="modal">确定</button>
												   <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
											   </div>
										   </div>
									   </div>
								   </div>
								   <div role="tabpanel" class="tab-pane fade active in" id="profile" aria-labelledby="profile-tab">
										<div class="form-three widget-shadow">
											<form id="uploadPic" action="#" enctype="multipart/form-data" class="form-horizontal">
												<div class="form-group">
													<label class="col-sm-2 control-label">门店名称</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopName" placeholder="不超过20个字符">
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">门店图片</label>
													<div id="imageForm" class="col-sm-2">
														<input type="file" name="file">
														<img id="image" src="">
													</div>
													<div class="col-sm-3">
														<button onclick="savePic();"> 上传 </button>
													</div>
													<div class="col-sm-4">
														<div class="checkbox-inline1 padding-15">支持jpg、rgb、png格式</div>
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">门店标语</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopBanner" placeholder="不超过20个字符">
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">门店简介</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopBriefIntroduction" placeholder="不超过20个字符">
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">门店介绍</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopIntroduce" placeholder="不超过20个字符">
													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-2 control-label">负责人</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopPersonalName" placeholder="不超过20个字符">
													</div>
												</div>
												<div class="form-group">
													<label  class="col-sm-2 control-label">门店地址</label>
													<div class="col-sm-8">
														省：<input type="text" class="form-control9" id="shopProvince" >&nbsp;&nbsp;&nbsp;
														市：<input type="text" class="form-control9" id="shopCity" >&nbsp;&nbsp;&nbsp;
														区：<input type="text" class="form-control9" id="shopArea" >
													</div>
												</div>
												<div class="form-group">
													<label  class="col-sm-2 control-label">详细地址</label>
													<div class="col-sm-8">
														<input type="text" class="form-control1" id="shopAddressDetail" maxlength="50" placeholder="不超过50个字符">
													</div>
												</div>
											</form>
											<div class="form-group margin-top-20">
													<label for="radio" class="col-sm-2 control-label"></label>
													<button type="button" class="btn btn-info" onclick="saveShop()">保 存</button>
											</div>
										</div>
									</div>
								<!---结束-->
								</div>
                                    <div role="tabpanel" class="tab-pane fade" id="dropdown1" aria-labelledby="dropdown1-tab"> 
                                     <p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p> 
                                    </div> 
                                    <div role="tabpanel" class="tab-pane fade" id="dropdown2" aria-labelledby="dropdown2-tab"> 
                                     <p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p> 
                                    </div> 
                               </div>                                
                                  <hr class="widget-separator">
                                        
                                        
                                    </div>
                                </div>
                            </div>
                    </div>
					<!--photoday-section-->	
						<div class="clearfix"></div>
                   
	<!--//photoday-section-->

	
				</div>
			</div>
		</div>
		<!--footer-->
		<div class="footer">
		   <p>敦化市建筑安装有限公司</p>
	   </div>
        <!--//footer-->
	</div>
	
	<!-- side nav js -->
	<script src='js/SidebarNav.min.js' type='text/javascript'></script>
	<script src='js/factory/common.js' type='text/javascript'></script>
	<script>
      $('.sidebar-menu').SidebarNav()
    </script>
	<!-- //side nav js -->
	
	<!-- Classie --><!-- for toggle left push menu script -->
	<script src="js/classie.js"></script>
	<script>
		var chooseShopId;
		var shopDeatil;
		var shopHeadPortrait;

		var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
			showLeftPush = document.getElementById( 'showLeftPush' ),
			body = document.body;

		showLeftPush.onclick = function() {
			classie.toggle( this, 'active' );
			classie.toggle( body, 'cbp-spmenu-push-toright' );
			classie.toggle( menuLeft, 'cbp-spmenu-open' );
			disableOther( 'showLeftPush' );
		};

		function disableOther( button ) {
			if( button !== 'showLeftPush' ) {
				classie.toggle( showLeftPush, 'disabled' );
			}
		}
		
		function uploadShopImage() {
			var formData = new FormData();
			formData.append('file', $('#file')[0].files[0]);
			$.ajax({
				url: prefixUrl + '/image/upload',
				type: 'POST',
				dataType:"json",
				cache: false,
				data: formData,
				processData: false,
				contentType: false
			}).done(function(res) {
				alert(res.data);
				document.getElementById("img").src = res.data;
			}).fail(function(res) {
				alert("fail");
			});
		}

		init();
		function init(){
			$.ajax({
				url	:	prefixUrl + "shop/queryList",
				type:	"post",
				data:JSON.stringify({"shopId":shopId,"commodityName":$("#commodityName").val()}),
				contentType:"application/json;",
				success:function(data){
                    goToLogin(data);
					var homeHtml = '<table class="table table-bordered" >'
							+'<thead>'
							+'<tr>'
							+'<th>店铺名称</th>'
							+'<th>店铺标题</th>'
							+'<th>责任人</th>'
							+'<th>操作</th>'
							+'</tr>'
							+'</thead>'
							+'<tbody>';
					var list = data.data.rows;
					for(var i=0; i<list.length; i++){
						var shopDetail = list[i];
						var homeHtml = homeHtml
								+'<tr>'
								+'<td>'
								+shopDetail.shopName
								+'</td>'
								+'<td>'
								+shopDetail.shopBanner
								+'</td>'
								+'<td>'
								+shopDetail.shopPersonalName
								+'</td>'
								+'<td>'
								+'<button class="badge badge-warning"  data-toggle="modal" data-target="#updateShop" onclick=setShopId("'
								+ list[i].id
								+ '") data-whatever="@mdo">修改</button>'
								+'<button class="badge badge-danger" onclick=deleteShop("'
								+ list[i].id
								+ '")>删除</button>'
								+'</td>'
								+'</tr>';
					}
					homeHtml = homeHtml
							+'</tbody>'
							+'</table>';
					$("#home").html(homeHtml)
				}
			})
		}

		function setShopId(id){
			chooseShopId = id;
			getShopDetail(chooseShopId);
		}

		function getShopDetail(chooseShopId){
			$.ajax({
				url: prefixUrl + "shop/queryDetail",
				type: "post",
				data: JSON.stringify({"id": chooseShopId}),
				contentType: "application/json;",
				success: function (data) {
					shopDeatil = data.data;
					$("#updateShopName").val(shopDeatil.shopName);
					$("#updateShopBanner").val(shopDeatil.shopBanner);
					$("#updateShopBriefIntroduction").val(shopDeatil.shopBriefIntroduction);
					$("#updateShopIntroduce").val(shopDeatil.shopIntroduce);
				}
			})
		}

		function updateShop(){
			$.ajax({
				url: prefixUrl + "shop/update",
				type: "post",
				data: JSON.stringify({"id": shopDeatil.id,"shopHeadPortrait":shopDeatil.shopHeadPortrait,"shopName":$("#updateShopName").val(),"shopBanner":$("#updateShopBanner").val(),"shopBriefIntroduction":$("#updateShopBriefIntroduction").val(),"shopIntroduce":$("#updateShopIntroduce").val()}),
				contentType: "application/json;",
				success: function (data) {
					alert(data.msg);
					init();
				}
			})
		}

		function deleteShop(id){
			$.ajax({
				url: prefixUrl + "shop/delete",
				type: "post",
				data: JSON.stringify({"id": id}),
				contentType: "application/json;",
				success: function (data) {
					alert(data.msg);
				}
			})
			init();
		}

		function savePic(){
			var formData = new FormData($( "#uploadPic" )[0]);
			$.ajax({
				type: "POST",
				//dataType: "text",
				url: prefixUrl + "image/upload",
				data: formData,
				async: false,
				cache: false,
				contentType: false,
				processData: false,
				success: function (data) {
					shopHeadPortrait = imageUrl + data;
					$("#image").attr("src",imageUrl + data);
				},
				error: function(data) {
					alert("error:"+data.responseText);
				}
			});
			return false;
		}

		function saveShop(){
			var shopData = {
				shopName	:	$("#shopName").val(),
				shopBanner:	$("#shopBanner").val(),
				shopHeadPortrait	:	shopHeadPortrait,
				shopBriefIntroduction	:	$("#shopBriefIntroduction").val(),
				shopIntroduce	:	$("#shopIntroduce").val(),
				shopPersonalName	:	$("#shopPersonalName").val(),
				shopProvince	:	$("#shopProvince").val(),
				shopCity	:	$("#shopCity").val(),
				shopArea	:	$("#shopArea").val(),
				shopAddressDetail	:	$("#shopAddressDetail").val()
			};
			$.ajax({
				url: prefixUrl + "shop/add",
				type: "post",
				data: JSON.stringify(shopData),
				contentType: "application/json;",
				success: function (data) {
					alert(data.msg);
					init();
				}
			})
		}
	</script>
	<!-- //Classie --><!-- //for toggle left push menu script -->
		
	<!--scrolling js-->
	<script src="js/jquery.nicescroll.js"></script>
	<script src="js/scripts.js"></script>
	<!--//scrolling js-->
	
	<!-- Bootstrap Core JavaScript -->
   <script src="js/bootstrap.js"> </script>
</body>
</html>